﻿<%@ Page Title="Right_RoleMemberList List" Language="C#" AutoEventWireup="true" CodeBehind="Right_RoleMemberList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Right.Right_RoleMemberList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;">添加成员</span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <form class="form-inline">
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>：</label>
                        <input type="email" id="MemberAccount" maxlength="45" name="MemberAccount" class="form-control" placeholder="<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>">
                    </div>
                    <button type="button" id="btnQuery" name="btnQuery" class="btn btn-default btn-ar btn-primary">
                        <i class="fa fa-search "></i>
                        <%: R(LanguageModule.M_Common, "Query") %>
                    </button>
                </form>
                <div class="form-group"></div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" id="btnEdit"><i class="fa fa-edit "></i>保存</a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Sys/Handlers/Sys_AdminInfoHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    //d.RoleID = "<%= WebHelper.Get("RoleID") %>";
                    //d.MemberAccount = $('#MemberAccount').val();
                },
            },
            "fnInitComplete": function (oSettings, json) {
                //alert('DataTables has finished its initialisation.');
                get();
            },
            "columns": [
                        {
                            data: "MemberAccount",
                            title: '<input type="checkbox" class="editor-active" id="all">',
                            width: 25,
                            render: function (data, type, row) {
                                return "<input type='checkbox' name='menu' class='" + row.MemberAccount + "' value='" + row.MemberAccount + "'> ";
                            },
                            className: "dt-body-center"
                        },
                    { "data": 'MemberAccount', "title": "<%: R(LanguageModule.Sys_AdminInfo, "MemberAccount", "会员帐号") %>" },
                    { "data": 'RoleName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "RoleName", "所属角色") %>" },
                    { "data": 'FirstName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "FirstName", "姓") %>" },
                    { "data": 'LastName', "title": "<%: R(LanguageModule.Sys_AdminInfo, "LastName", "名") %>" },
                    { "data": 'Sex', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Sex", "性别") %>", render: fYesNo },
                    { "data": 'Email', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Email", "Email") %>" },
                    { "data": 'MobileNo', "title": "<%: R(LanguageModule.Sys_AdminInfo, "MobileNo", "手机号") %>" },
                    { "data": 'Memo', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Memo", "备注") %>" },
                    { "data": 'Status', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Status", "状态") %>", render: fnumber },
                    { "data": 'Creator', "title": "<%: R(LanguageModule.Sys_AdminInfo, "Creator", "创建人") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Sys_AdminInfo, "CreateTime", "创建时间") %>" },
                    { "data": 'IsModify', "title": "<%: R(LanguageModule.Sys_AdminInfo, "IsModify", "是否可修改") %>", render: fYesNo },
                    { "data": 'HKCreateTime', "title": "<%: R(LanguageModule.Sys_AdminInfo, "HKCreateTime", "HKCreateTime") %>" },
            ],
            rowCallback:
                function (row, data) {
                    // Set the checked state of the checkbox in the table
                    $(row).find('input:checkbox').prop('checked', false);
                }

        });
        

        $('#btnQuery').click(function () {
            dt.ajax.reload();
        });

        //保存
        $('#btnEdit').click(function () {
                var menuInfos = "";
                $("input[name='menu']:checked").each(function () {
                    menuInfos = menuInfos + this.value + ",";
                });
                if (menuInfos == "") {
                    $(".alert > .content").html("<%: R(LanguageModule.Right_RoleRight, "AddMemberRole","对不起，还未选取任何管理员！") %>");
                    $(".alert").show();
                    return false;
                }
                $.post("Right/Handlers/Right_MemberRoleHandler.ashx?type=addRoleMember", { RoleID: "<%= WebHelper.Get("RoleID") %>", MemberAccountS: menuInfos }, function (data) {
                    $(".alert > .content").html(data.message);
                    $(".alert").show();
                }, 'json');
        });

        //全选/取消全选
        $('#all').toggle(function () {
            $("input[name='menu']").prop("checked", true);
        }, function () {
            $("input[name='menu']").removeAttr("checked");
        });
    });
    function get() {
        $.post("Right/Handlers/Right_MemberRoleHandler.ashx?type=list", { RoleID: "<%= WebHelper.Get("RoleID") %>" }, function (data) {
            $("input").each(function () {
                $("input[name='menu']").prop("checked", false);
            });
            if (data.checkMenuInfo != "") {
                var menuarr = data.checkMenuInfo.split(',');

                //  $("input").each(function () {
                for (var i = 0; i < menuarr.length; i++) {
                    //alert(menuarr[i]);
                    $("." + menuarr[i] + "").prop('checked', true);
                }

                // });
            }
        }, 'json');
    }
</script>
